<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>物业管理系统</title>
		
		<base href="<%=basePath%>">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/vivo.css">
		<link rel="stylesheet" href="css/cmxform.css">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css" />
		<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css" />
		
		<script src="js/jquery-1.11.1.js"></script>
		<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
		<script src="js/select2/select2.min.js"></script>
		<script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
		<script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
		<script type="text/javascript" src="js/sharefunction.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css" />
		<style type="text/css">
			.primary-vdd {
				color: #fff;
				background-color: #5a98de;
				border-color: #5a98de
			}
			
			.primary-vdd:hover {
				color: #fff;
				background-color: #0a6999;
				border-color: #0a6999
			}
		</style>
		<script type="text/javascript">
			$.validator.setDefaults({
				submitHandler : function() {
					saveDocument();
				}
			});
		
			$(document).ready(function() {
				
				$("#parentId").select2({
					minimumResultsForSearch : -1
				});
				$("#orgType").select2({
					minimumResultsForSearch : -1
				});
				$("#orgProperty").select2({
					minimumResultsForSearch : -1
				});
				
				$("#commentForm").validate({
					errorPlacement : function(error, element) {
						// Append error within linked label
						$(element).next().append(error);
					},
					errorElement : "span",
					rules : {
						reading : {
							maxlength : 9,
							max : 999999,
							min : 0
						}
					},
					messages : {
						typeName : {
							required : " 必需字段!",
							minlength : " (不能少于 3 个字母)"
						},
						unitNumber : {
							required : " 必须字段！ "
						},
						watchNo : {
							number : "请输入合法编号！ "
						},
						reading : {
							maxlength : "输入的数字超范围",
							max : "输入的数字超范围",
							min : "输入的数字超范围",
							number : "请输入合法数字! ",
							required : "请输入最新读数！ "
						},
						watchName : {
							required : "请输入表具名称！"
						},
		
						readTime : {
							required : "请输入读数日期！ "
						}
					}
		
				});
			});
		
			function saveDocument() {
				var roomInfo = $("#roomInfo").val();
				var watchType = $("#watchType").val();
				var watchName = $("#watchName").val();
				var watchNo = $("#watchNo").val();
				var reading = $("#reading").val();
				var readTime = $("#readTime").val();
				//layer.confirm("确定保存吗？",{icon:3},function(i){
				var url = "room/roomWatch/add1";
				jQuery.ajax({
					type : "post",
					async : false,
					url : url,
					dataType : "json",
					data : {
						watchType : watchType,
						watchName : watchName,
						watchNo : watchNo,
						reading : reading,
						readTime : readTime,
						roomInfoId : roomInfo
					},
					success : function(data) {
						if (data.success) {
							window.parent.layer.msg('保存成功！');
							var recordId = "aa1123";
							var indext = "1";
							var params = "&recordId=" + recordId + "&indext="
									+ indext;
							window.parent.gridObj4.options.otherParames = params;
							window.parent.gridObj4.refreshPage();
							window.parent.gridObj.refreshPage();
							window.parent.document
									.getElementById("xinzengbianjidushu").style.display = 'none';
							closeLayer();

						} else {
							layer.alert(data.msg, {
								icon : 7
							});
						}
					}
				});
			}
		</script>
	
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
			<div style="padding: 20px">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h5 class="panel-title">部门信息</h5>
					</div>
					<div class="panel-body">
						<table cellpadding="10" cellspacing="5" class="mytable">
							<tr>
								<td width="90">上级组织</td>
								<td width="250px">
									<select id="parentId" style="width: 90px;">
									</select>
								</td>
								<td width="90">组织排序</td>
								<td>
									<input type="text" name="sortNum" id="sortNum" >
								</td>
							</tr>
							<tr>
								<td width="90">组织名称</td>
								<td>
									<input type="text" name="orgName" id="orgName" required />
									<font color="red"> *</font>
									<span style="color: red"></span>
								</td>
								<td width="90">组织编号</td>
								<td>
									<input type="text" name="orgCode" id="orgCode" >
									<span style="color: red"></span>
								</td>
							</tr>
							<tr>
								<td width="90">组织类型</td>
								<td>
									<select id="orgType" style="width: 90px;">
										<option value="0">部门</option>
										<option value="1">公司</option>
									</select>
								</td>
								<td width="90">组织性质</td>
								<td>
									<select id="orgProperty" style="width: 90px;">
										<option value="0">职能部门</option>
										<option value="1">项目部门</option>
									</select>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div style="width: 100%; text-align: center; padding-top: 20px">
					<button class="btn btn-primary radius primary-vdd" type="submit">保 存</button>
					<a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a>
					<br />
					<br />
				</div>
			</div>
	
			<div style="display:none">
				<input id="id" name="id" type="hidden" value="${id}" />
			</div>
		</form>
	</body>
</html>

